package com.jsg.sl651.message.handler;

import com.jsg.sl651.entity.data.Element;
import com.jsg.sl651.entity.frame.FrameMessageWrapper;
import com.jsg.sl651.entity.frame.body.MessageBody;
import com.jsg.sl651.entity.frame.body.returns.ReturnMessageBody;
import com.jsg.sl651.util.SL651Tool;
import lombok.extern.slf4j.Slf4j;

import java.util.List;


@Slf4j
public class DefaultHandler implements Handler{
    /**
     * 处理具体的消息
     * @param frameMessageWrapper
     * @return
     */
    @Override
    public ReturnMessageBody handle(FrameMessageWrapper frameMessageWrapper) {
        SL651Tool.logFrameMessageWrapper(frameMessageWrapper,log);
        MessageBody body = frameMessageWrapper.getBody();
        if (body != null) {
            List<Element<?>> dataElements = body.getDataElements();
            for (Element<?> dataElement : dataElements) {
                log.info("数据元素" +
                        "\r\n{}",dataElement);
            }
        }
        return null;
    }
}
